package MyProperties;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.io.FileReader;;
import java.util.Properties;
import java.util.Set;

public class demo2 {
    public static void main(String[] args) throws Exception {
        //先创建一个容器 Properties
        Properties properties = new Properties();
        //接着通过load方法将文件中的数据写到容器里
        properties.load(new FileReader("D:\\software\\code\\2023_java\\2023_java_code\\code_24_4_29\\src\\MyProperties\\text.properties"));
        //再把容器中的数据读取出来
        //根据一个键来获取一个值的方式
        String value = properties.getProperty("小明");
        System.out.println(value);
        String value1 = properties.getProperty("小板");
        System.out.println(value1);
        String value2 = properties.getProperty("小童");
        System.out.println(value2);
        System.out.println("======================");

        //获取全部键
        Set<String> set = properties.stringPropertyNames();
        for (String s : set) {
            System.out.println(s + " :" + properties.getProperty(s));
        }
    }
}
